package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * PROJECT_NAME: sky-take-out
 * NAME: CategoryController
 * USER: zhang
 * DATE: 2023/5/21
 * DESCRIPTION : C端-分类信息表现层接口
 */
@Slf4j
@RestController("userCategoryController")
@Api(tags = "C端-分类信息表现层接口")
@RequestMapping("/user/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    /**
     * 查询所有可用分类信息
     *
     * @param type 类型
     * @return 全局通用返回信息Bean(分类List集合)
     */
    @ApiOperation("C端-查询所有可用分类信息")
    @GetMapping("/list")
    public Result<List<Category>> selectCategoryByType( Integer type){
        List<Category> categoryList= categoryService.selectByType(type);
        return Result.success(categoryList);
    }
}
